<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/**
 * Smarty truncatey modifier plugin
 *
 * Type:     modifier<br>
 * Name:     truncatey<br>
 * Purpose:  Truncate a string to a certain length if necessary,
 * optionally splitting in the middle of a word, and
 * appending the $etc string or inserting $etc into the middle.
 * @author   Monte Ohrt <monte at ohrt dot com> modify by leijuly
 * @param string
 * @param integer
 * @param string
 * @param boolean
 */
function smarty_modifier_truncatey($string, $length = 80, $etc = '...', $count_words = true) {
	$l = strlen($string);
	if ($l > $length) {
		$string =  mb_strcut($string, 0, $length-strlen($etc)).$etc;
	}
	return $string;
}

/* vim: set expandtab: */

?>